/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package battleship.board;

import battleship.ship.ShipType;

/**
 *
 * @author ali
 */
abstract public class AbstractLocation implements LocationType {

    boolean isHit = false;
    ShipType ship;

    public boolean isHit() {
        return isHit;
    }

    public boolean hit() {
        if (isHit == true) {
            //If the location is already hit return false, indicating a incorrect judgement.
            return false;
        }
        isHit = true;
        return true;

    }

    public ShipType getShip(){
        return ship;
    }

    public boolean containsShip(){
        boolean containsShip = false;
        if(ship != null){
            containsShip = true;
        }
        return containsShip;
    }

    public boolean setShip(ShipType ship){
        boolean successfullyShipPlaced = false;
        if(!containsShip()){
            this.ship = ship;
            successfullyShipPlaced = true;
        }
        return successfullyShipPlaced;
    }
    
}
